package gui;

import gui.panels.DomainDrawPanel;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;
import javax.swing.JToolBar;
import javax.swing.JProgressBar;
import java.awt.Font;
import javax.swing.JScrollPane;
import gui.lang.*;

public class GuiMain extends JFrame {
//--
	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JMenuBar jJMenuBar = null;
	//menus
	private JMenu menuFile = null;
	private JMenu menuEdit = null;
	private JMenu menuView = null;
	private JMenu menuSolve = null;
	private JMenu menuHelp = null;
	//file menu items
	private JMenuItem menuItemProjectNew = null;
	private JMenuItem menuItemProjectOpen = null;
	private JMenuItem menuItemProjectSave = null;
	private JMenuItem menuItemDomainOpen = null;
	private JMenuItem menuItemDomainSave = null;
	private JMenuItem menuItemObjectOpen = null;
	private JMenuItem menuItemObjectSave = null;
	private JMenuItem menuItemObjectCollectionOpen = null;
	private JMenuItem menuItemObjectCollectionSave = null;
	private JMenuItem menuItemImport = null;
	private JMenuItem menuItemExport = null;
	private JMenuItem menuItemProgramExit = null;
	//edit menu items
	private JMenuItem menuItemObjectNew = null;
	private JMenuItem menuItemObjectClone = null;
	private JMenuItem menuItemObjectEdit = null;
	private JMenuItem menuItemObjectRemove = null;
	private JMenuItem MenuItemSettings = null;
	private JMenuItem menuItemEditDomain = null;
	//view menu items
	private JMenuItem MenuItemZoomIn = null;
	private JMenuItem MenuItemZoomOut = null;
	private JMenuItem MenuItemFitPage = null;
	//solve menu items
	private JMenuItem MenuItemRun = null;
	//help menu items
	private JMenuItem MenuItemHelp = null;
	private JMenuItem MenuItemAbout = null;
	//tool bar
	private JToolBar toolBar = null;
	private JButton toolBarNew = null;
	private JButton toolBarOpen = null;
	private JButton toolBarSave = null;
	private JButton toolBarDomainOpen = null;
	private JButton toolBarDomainSave = null;
	private JButton toolBarCollectionOpen = null;
	private JButton toolBarCollectionSave = null;
	private JButton toolBarObjectOpen = null;
	private JButton toolBarObjectSave = null;
	private JButton toolBarRun = null;
	private JButton toolBarObjectNew = null;
	private JButton toolBarObjectClone = null;
	private JButton toolBarObjectEdit = null;
	private JButton toolBarObjectRemove = null;
	private JButton toolBarDomainEdit = null;
	private JButton toolBarSettings = null;
	private JButton toolBarZoomIn = null;
	private JButton toolBarZoomOut = null;
	private JButton toolBarFitPage = null;
	//side pane
	private JPanel sidePanel = null;
	private JPanel lowerPanel;
	private JProgressBar progressBar;
	private JScrollPane scrollPane;
	private DomainDrawPanel dp;
	
	/**
	 * This is the default constructor
	 */
	public GuiMain() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(600, 400);
		this.setJMenuBar(getJJMenuBar());
		this.setContentPane(getJContentPane());
		this.setTitle("JFrame");
		
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(new BorderLayout());
			jContentPane.add(getToolBar(), BorderLayout.NORTH);
			jContentPane.add(getSidePanel(),BorderLayout.EAST);
			jContentPane.add(getLowerPanel(), BorderLayout.SOUTH);
			jContentPane.add(getScrollPane(), BorderLayout.CENTER);
		}
		return jContentPane;
	}


	//------------------------------------------------------------------------------
	//------------------------------------------------------------------------------
	//-------------------------Main Menu--------------------------------------------
	//------------------------------------------------------------------------------
	//------------------------------------------------------------------------------
	
	private JMenuBar getJJMenuBar() {
		if (jJMenuBar == null) {
			jJMenuBar = new JMenuBar();
			jJMenuBar.add(getMenuFile());
			jJMenuBar.add(getMenuEdit());
			jJMenuBar.add(getMenuView());
			jJMenuBar.add(getMenuSolve());
			jJMenuBar.add(getMenuHelp());
		}
		return jJMenuBar;
	}

	private JMenu getMenuFile() {
		if (menuFile == null) {
			menuFile = new JMenu();
			menuFile.setText(Lang.MENU_FILE);
			menuFile.add(getMenuItemProjectNew());
			menuFile.add(getMenuItemProjectOpen());
			menuFile.add(getMenuItemProjectSave());
			menuFile.addSeparator();
			menuFile.add(getMenuItemDomainOpen());
			menuFile.add(getMenuItemDomainSave());
			menuFile.addSeparator();
			menuFile.add(getMenuItemObjectOpen());
			menuFile.add(getMenuItemObjectSave());
			menuFile.addSeparator();
			menuFile.add(getMenuItemObjectCollectionOpen());
			menuFile.add(getMenuItemObjectCollectionSave());
			menuFile.addSeparator();
			menuFile.add(getMenuItemImport());
			menuFile.add(getMenuItemExport());
			menuFile.addSeparator();
			menuFile.add(getMenuItemProgramExit());
		}
		return menuFile;
	}

	private JMenu getMenuEdit() {
		if (menuEdit == null) {
			menuEdit = new JMenu();
			menuEdit.setText(Lang.MENU_EDIT);
			menuEdit.add(getMenuItemObjectNew());
			menuEdit.add(getMenuItemObjectClone());
			menuEdit.add(getMenuItemObjectEdit());
			menuEdit.add(getMenuItemObjectRemove());
			menuEdit.addSeparator();
			menuEdit.add(getMenuItemEditDomain());
			menuEdit.addSeparator();
			menuEdit.add(getMenuItemSettings());
		}
		return menuEdit;
	}

	private JMenu getMenuView() {
		if (menuView == null) {
			menuView = new JMenu();
			menuView.setText(Lang.MENU_VIEW);
			menuView.add(getMenuItemZoomIn());
			menuView.add(getMenuItemZoomOut());
			menuView.add(getMenuItemFitPage());
		}
		return menuView;
	}

	private JMenu getMenuSolve() {
		if (menuSolve == null) {
			menuSolve = new JMenu();
			menuSolve.setText(Lang.MENU_SOLVE);
			menuSolve.add(getMenuItemRun());
		}
		return menuSolve;
	}

	private JMenu getMenuHelp() {
		if (menuHelp == null) {
			menuHelp = new JMenu();
			menuHelp.setText(Lang.MENU_HELP);
			menuHelp.add(getMenuItemHelp());
			menuHelp.add(getMenuItemAbout());
		}
		return menuHelp;
	}

	//-------------------------------------------------------------------------------------------
	//----------------------------------------Menu Items Action----------------------------------
	//-------------------------------------------------------------------------------------------
	
	//----------------------------File Menu------------------------------------------------------
	private JMenuItem getMenuItemProjectNew() {
		if (menuItemProjectNew == null) {
			menuItemProjectNew = new JMenuItem(Lang.MENU_FILE_PROJECT_NEW, new ImageIcon("icons/project_new.png")	);
			menuItemProjectNew.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
			menuItemProjectNew.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_project_new();
				}
			});
		}
		return menuItemProjectNew;
	}
	
	private JMenuItem getMenuItemProjectOpen() {
		if (menuItemProjectOpen == null) {
			menuItemProjectOpen = new JMenuItem(Lang.MENU_FILE_PROJECT_OPEN, new ImageIcon("icons/project_open.png")	);
			menuItemProjectOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
			menuItemProjectOpen.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_project_open();
				}
			});
		}
		return menuItemProjectOpen;
	}
	
	private JMenuItem getMenuItemProjectSave() {
		if (menuItemProjectSave == null) {
			menuItemProjectSave = new JMenuItem(Lang.MENU_FILE_PROJECT_SAVE, new ImageIcon("icons/project_save.png")	);
			menuItemProjectSave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
			menuItemProjectSave.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_project_save();
				}
			});
		}
		return menuItemProjectSave;
	}
	
	private JMenuItem getMenuItemDomainOpen() {
		if (menuItemDomainOpen == null) {
			menuItemDomainOpen = new JMenuItem(Lang.MENU_FILE_DOMAIN_OPEN, new ImageIcon("icons/domain_open.png")	);
			menuItemDomainOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.ALT_MASK));
			menuItemDomainOpen.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_domain_open();
				}
			});
		}
		return menuItemDomainOpen;
	}
	
	private JMenuItem getMenuItemDomainSave() {
		if (menuItemDomainSave == null) {
			menuItemDomainSave = new JMenuItem(Lang.MENU_FILE_DOMAIN_SAVE, new ImageIcon("icons/domain_save.png")	);
			menuItemDomainSave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.ALT_MASK));
			menuItemDomainSave.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_domain_save();
				}
			});
		}
		return menuItemDomainSave;
	}
	
	private JMenuItem getMenuItemObjectOpen() {
		if (menuItemObjectOpen == null) {
			menuItemObjectOpen = new JMenuItem(Lang.MENU_FILE_OBJECT_OPEN, new ImageIcon("icons/object_open.png")	);
			menuItemObjectOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, ActionEvent.ALT_MASK));
			menuItemObjectOpen.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_object_open();
				}
			});
		}
		return menuItemObjectOpen;
	}
	
	private JMenuItem getMenuItemObjectSave() {
		if (menuItemObjectSave == null) {
			menuItemObjectSave = new JMenuItem(Lang.MENU_FILE_OBJECT_SAVE, new ImageIcon("icons/object_save.png")	);
			menuItemObjectSave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK));
			menuItemObjectSave.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_object_save();
				}
			});
		}
		return menuItemObjectSave;
	}
	
	private JMenuItem getMenuItemObjectCollectionOpen() {
		if (menuItemObjectCollectionOpen == null) {
			menuItemObjectCollectionOpen = new JMenuItem(Lang.MENU_FILE_COLLECTION_OPEN, new ImageIcon("icons/collection_open.png")	);
			menuItemObjectCollectionOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.SHIFT_MASK));
			menuItemObjectCollectionOpen.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_collection_open();
				}
			});
		}
		return menuItemObjectCollectionOpen;
	}
	
	private JMenuItem getMenuItemObjectCollectionSave() {
		if (menuItemObjectCollectionSave == null) {
			menuItemObjectCollectionSave = new JMenuItem(Lang.MENU_FILE_COLLECTION_SAVE, new ImageIcon("icons/collection_save.png")	);
			menuItemObjectCollectionSave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.SHIFT_MASK));
			menuItemObjectCollectionSave.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_collection_save();
				}
			});
		}
		return menuItemObjectCollectionSave;
	}
	
	private JMenuItem getMenuItemImport() {
		if (menuItemImport == null) {
			menuItemImport = new JMenuItem(Lang.MENU_FILE_IMPORT, new ImageIcon("icons/import.png")	);
			menuItemImport.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.SHIFT_MASK));
			menuItemImport.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_import();
				}
			});
		}
		return menuItemImport;
	}
	
	private JMenuItem getMenuItemExport() {
		if (menuItemExport == null) {
			menuItemExport = new JMenuItem(Lang.MENU_FILE_EXPORT, new ImageIcon("icons/export.png")	);
			menuItemExport.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.SHIFT_MASK));
			menuItemExport.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_export();
				}
			});
		}
		return menuItemExport;
	}
	
	private JMenuItem getMenuItemProgramExit() {
		if (menuItemProgramExit == null) {
			menuItemProgramExit = new JMenuItem(Lang.MENU_FILE_EXIT, new ImageIcon("icons/exit.png")	);
			menuItemProgramExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK));
			menuItemProgramExit.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					dispose();
				}
			});
		}
		return menuItemProgramExit;
	}

	//----------------------------Edit Menu------------------------------------------------------
	
	private JMenuItem getMenuItemObjectNew() {
		if (menuItemObjectNew == null) {
			menuItemObjectNew = new JMenuItem(Lang.MENU_EDIT_OBJECT_NEW, new ImageIcon("icons/object_new.png")	);
			menuItemObjectNew.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.ALT_MASK));
			menuItemObjectNew.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_object_new();
				}
			});
		}
		return menuItemObjectNew;
	}
	
	private JMenuItem getMenuItemObjectClone() {
		if (menuItemObjectClone == null) {
			menuItemObjectClone = new JMenuItem(Lang.MENU_EDIT_OBJECT_CLONE, new ImageIcon("icons/object_clone.png")	);
			menuItemObjectClone.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.ALT_MASK));
			menuItemObjectClone.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_object_clone();
				}
			});
		}
		return menuItemObjectClone;
	}
	
	
	private JMenuItem getMenuItemObjectEdit() {
		if (menuItemObjectEdit == null) {
			menuItemObjectEdit = new JMenuItem(Lang.MENU_EDIT_OBJECT_EDIT, new ImageIcon("icons/object_edit.png"));
			menuItemObjectEdit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.ALT_MASK));
			menuItemObjectEdit.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_object_edit();
				}
			});
		}
		return menuItemObjectEdit;
	}
	
	private JMenuItem getMenuItemObjectRemove() {
		if (menuItemObjectRemove == null) {
			menuItemObjectRemove = new JMenuItem(Lang.MENU_EDIT_OJBECT_REMOVE, new ImageIcon("icons/object_remove.png")	);
			menuItemObjectRemove.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.ALT_MASK));
			menuItemObjectRemove.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_object_remove();
				}
			});
		}
		return menuItemObjectRemove;
	}
	
	private JMenuItem getMenuItemEditDomain() {
		if (menuItemEditDomain == null) {
			menuItemEditDomain = new JMenuItem(Lang.MENU_EDIT_EDIT_DOMAIN, new ImageIcon("icons/domain_edit.png"));
			menuItemEditDomain.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.CTRL_MASK));
			menuItemEditDomain.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_edit_domain();
				}
			});
		}
		return menuItemEditDomain;
	}
	
	private JMenuItem getMenuItemSettings() {
		if (MenuItemSettings == null) {
			MenuItemSettings = new JMenuItem(Lang.MENU_EDIT_SETTINGS, new ImageIcon("icons/settings.png"));
			MenuItemSettings.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));
			MenuItemSettings.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_settings();
				}
			});
		}
		return MenuItemSettings;
	}
	
	//----------------------------View Menu------------------------------------------------------
	
	private JMenuItem getMenuItemZoomIn() {
		if (MenuItemZoomIn == null) {
			MenuItemZoomIn = new JMenuItem(Lang.MENU_VIEW_ZOOM_IN, new ImageIcon("icons/zoom_in.png"));
			MenuItemZoomIn.setMnemonic(KeyEvent.VK_PAGE_UP);
			MenuItemZoomIn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0));
			MenuItemZoomIn.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_zoom_in();
				}
			});
		}
		return MenuItemZoomIn;
	}
	
	private JMenuItem getMenuItemZoomOut() {
		if (MenuItemZoomOut == null) {
			MenuItemZoomOut = new JMenuItem(Lang.MENU_VIEW_ZOOM_OUT, new ImageIcon("icons/zoom_out.png"));
			MenuItemZoomOut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0));
			MenuItemZoomOut.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_zoom_out();
				}
			});
		}
		return MenuItemZoomOut;
	}
	
	private JMenuItem getMenuItemFitPage() {
		if (MenuItemFitPage == null) {
			MenuItemFitPage = new JMenuItem(Lang.MENU_VIEW_ZOOM_FIT, new ImageIcon("icons/zoom_fit.png"));
			MenuItemFitPage.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0));
			MenuItemFitPage.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_fit_page();
				}
			});
		}
		return MenuItemFitPage;
	}
	
	//----------------------------Solve Menu------------------------------------------------------
	
	private JMenuItem getMenuItemRun() {
		if (MenuItemRun == null) {
			MenuItemRun = new JMenuItem(Lang.MENU_SOLVE_RUN, new ImageIcon("icons/run.png"));
			MenuItemRun.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK));
			MenuItemRun.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_run();
				}
			});
		}
		return MenuItemRun;
	}
	
	//----------------------------Help Menu------------------------------------------------------
	private JMenuItem getMenuItemHelp() {
		if (MenuItemHelp == null) {
			MenuItemHelp = new JMenuItem(Lang.MENU_HELP_HELP, new ImageIcon("icons/help.png"));
			MenuItemHelp.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
			MenuItemHelp.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_help();
				}
			});
		}
		return MenuItemHelp;
	}
	
	private JMenuItem getMenuItemAbout() {
		if (MenuItemAbout == null) {
			MenuItemAbout = new JMenuItem(Lang.MENU_HELP_ABOUT, new ImageIcon("icons/about.png"));
			MenuItemAbout.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0));
			MenuItemAbout.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_about();
				}
			});
		}
		return MenuItemAbout;
	}
	
	//------------------------------------------------------------------------------
	//------------------------------------------------------------------------------
	//-------------------------Tool Bar Menu----------------------------------------
	//------------------------------------------------------------------------------
	//------------------------------------------------------------------------------
	
	private JToolBar getToolBar() {
		if (toolBar == null) {
			toolBar = new JToolBar();
			toolBar.add(getToolBarNew());
			toolBar.add(getToolBarOpen());
			toolBar.add(getToolBarSave());
			toolBar.addSeparator();
			toolBar.add(getToolBarDomainOpen());
			toolBar.add(getToolBarDomainSave());
			toolBar.addSeparator();
			toolBar.add(getToolBarCollectionOpen());
			toolBar.add(getToolBarCollectionSave());
			toolBar.addSeparator();
			toolBar.add(getToolBarObjectOpen());
			toolBar.add(getToolBarObjectSave());
			toolBar.addSeparator();
			toolBar.add(getToolBarRun());
			toolBar.addSeparator();
			toolBar.add(getToolBarObjectNew());
			toolBar.add(getToolBarObjectClone());
			toolBar.add(getToolBarObjectEdit());
			toolBar.add(getToolBarObjectRemove());
			toolBar.addSeparator();
			toolBar.add(getToolBarDomainEdit());
			toolBar.addSeparator();
			toolBar.add(getToolBarZoomIn());
			toolBar.add(getToolBarZoomOut());
			toolBar.add(getToolBarFitPage());
			toolBar.addSeparator();
			toolBar.add(getToolBarSettings());
		
			
		}
		return toolBar;
	}
	
	private JButton getToolBarNew(){
		if (toolBarNew == null){
			toolBarNew = new JButton(new ImageIcon("icons/project_new.png"));
			toolBarNew.setToolTipText(Lang.TOOLBAR_PROJECT_NEW);
			toolBarNew.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_project_new();
				}
			});
		}
		
		return toolBarNew;
	}
	
	private JButton getToolBarOpen(){
		if (toolBarOpen == null){
			toolBarOpen = new JButton(new ImageIcon("icons/project_open.png"));
			toolBarOpen.setToolTipText(Lang.TOOLBAR_PROJECT_OPEN);
			toolBarOpen.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_project_open();
				}
			});
		}
		
		return toolBarOpen;
	}
	
	private JButton getToolBarSave(){
		if (toolBarSave == null){
			toolBarSave = new JButton(new ImageIcon("icons/project_save.png"));
			toolBarSave.setToolTipText(Lang.TOOLBAR_PROJECT_SAVE);
			toolBarSave.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_project_save();
				}
			});
		}
		
		return toolBarSave;
	}
	
	private JButton getToolBarDomainOpen(){
		if (toolBarDomainOpen == null){
			toolBarDomainOpen = new JButton(new ImageIcon("icons/domain_open.png"));
			toolBarDomainOpen.setToolTipText(Lang.TOOLBAR_DOMAIN_OPEN);
			toolBarDomainOpen.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_domain_open();
				}
			});
		}
		
		return toolBarDomainOpen;
	}
	
	private JButton getToolBarDomainSave(){
		if (toolBarDomainSave == null){
			toolBarDomainSave = new JButton(new ImageIcon("icons/domain_save.png"));
			toolBarDomainSave.setToolTipText(Lang.TOOLBAR_DOMAIN_SAVE);
			toolBarDomainSave.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_domain_save();
				}
			});
		}
		
		return toolBarDomainSave;
	}
	
	private JButton getToolBarCollectionOpen(){
		if (toolBarCollectionOpen == null){
			toolBarCollectionOpen = new JButton(new ImageIcon("icons/collection_open.png"));
			toolBarCollectionOpen.setToolTipText(Lang.TOOLBAR_COLLECTION_OPEN);
			toolBarCollectionOpen.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_collection_open();
				}
			});
		}
		
		return toolBarCollectionOpen;
	}
	
	private JButton getToolBarCollectionSave(){
		if (toolBarCollectionSave == null){
			toolBarCollectionSave = new JButton(new ImageIcon("icons/collection_save.png"));
			toolBarCollectionSave.setToolTipText(Lang.TOOLBAR_COLLECTION_SAVE);
			toolBarCollectionSave.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_collection_save();
				}
			});
		}
		
		return toolBarCollectionSave;
	}
	
	private JButton getToolBarObjectOpen(){
		if (toolBarObjectOpen == null){
			toolBarObjectOpen= new JButton(new ImageIcon("icons/object_open.png"));
			toolBarObjectOpen.setToolTipText(Lang.TOOLBAR_OBJECT_OPEN);
			toolBarObjectOpen.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_object_open();
				}
			});
		}
		
		return toolBarObjectOpen;
	}
	
	private JButton getToolBarObjectSave(){
		if (toolBarObjectSave == null){
			toolBarObjectSave = new JButton(new ImageIcon("icons/object_save.png"));
			toolBarObjectSave.setToolTipText(Lang.TOOLBAR_PROJECT_SAVE);
			toolBarObjectSave.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_object_save();
				}
			});
		}
		
		return toolBarObjectSave;
	}
	
	private JButton getToolBarRun(){
		if (toolBarRun == null){
			toolBarRun = new JButton(new ImageIcon("icons/run.png"));
			toolBarRun.setToolTipText(Lang.TOOLBAR_RUN);
			toolBarRun.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_run();
				}
			});
		}
		
		return toolBarRun;
	}
	
	private JButton getToolBarObjectNew(){
		if (toolBarObjectNew == null){
			toolBarObjectNew = new JButton(new ImageIcon("icons/object_new.png"));
			toolBarObjectNew.setToolTipText(Lang.TOOLBAR_OBJECT_NEW);
			toolBarObjectNew.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_object_new();
				}
			});
		}
		
		return toolBarObjectNew;
	}
	
	private JButton getToolBarObjectClone(){
		if (toolBarObjectClone == null){
			toolBarObjectClone = new JButton(new ImageIcon("icons/object_clone.png"));
			toolBarObjectClone.setToolTipText(Lang.TOOLBAR_OBJECT_CLONE);
			toolBarObjectClone.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_object_clone();
				}
			});
		}
		
		return toolBarObjectClone;
	}
	
	private JButton getToolBarObjectEdit(){
		if (toolBarObjectEdit == null){
			toolBarObjectEdit = new JButton(new ImageIcon("icons/object_edit.png"));
			toolBarObjectEdit.setToolTipText(Lang.TOOLBAR_OBJECT_EDIT);
			toolBarObjectEdit.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_object_edit();
				}
			});
		}
		
		return toolBarObjectEdit;
	}
	
	private JButton getToolBarObjectRemove(){
		if (toolBarObjectRemove == null){
			toolBarObjectRemove = new JButton(new ImageIcon("icons/object_remove.png"));
			toolBarObjectRemove.setToolTipText(Lang.TOOLBAR_OBJECT_REMOVE);
			toolBarObjectRemove.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_object_remove();
				}
			});
		}
		
		return toolBarObjectRemove;
	}
	
	private JButton getToolBarDomainEdit(){
		if (toolBarDomainEdit == null){
			toolBarDomainEdit = new JButton(new ImageIcon("icons/domain_edit.png"));
			toolBarDomainEdit.setToolTipText(Lang.TOOLBAR_DOMAIN_EDIT);
			toolBarDomainEdit.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_edit_domain();
				}
			});
		}
		
		return toolBarDomainEdit;
	}
	
	private JButton getToolBarSettings(){
		if (toolBarSettings == null){
			toolBarSettings = new JButton(new ImageIcon("icons/settings.png"));
			toolBarSettings.setToolTipText(Lang.TOOLBAR_SETTINGS);
			toolBarSettings.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_settings();
				}
			});
		}
		
		return toolBarSettings;
	}
	
	private JButton getToolBarZoomIn(){
		if (toolBarZoomIn == null){
			toolBarZoomIn = new JButton(new ImageIcon("icons/zoom_in.png"));
			toolBarZoomIn.setToolTipText(Lang.TOOLBAR_ZOOM_IN);
			toolBarZoomIn.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_zoom_in();
				}
			});
		}
		
		return toolBarZoomIn;
	}
	
	private JButton getToolBarZoomOut(){
		if (toolBarZoomOut == null){
			toolBarZoomOut = new JButton(new ImageIcon("icons/zoom_out.png"));
			toolBarZoomOut.setToolTipText(Lang.TOOLBAR_ZOOM_OUT);
			toolBarZoomOut.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_zoom_out();
				}
			});
		}
		
		return toolBarZoomOut;
	}
	
	private JButton getToolBarFitPage(){
		if (toolBarFitPage == null){
			toolBarFitPage = new JButton(new ImageIcon("icons/zoom_fit.png"));
			toolBarFitPage.setToolTipText(Lang.TOOLBAR_ZOOM_FIT);
			toolBarFitPage.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					action_fit_page();
				}
			});
		}
		
		return toolBarFitPage;
	}
	
	//-----------------------------------------------------------------------------
	//-----------------------------Side Panel--------------------------------------
	//-----------------------------------------------------------------------------
	
	private JPanel getSidePanel(){
		if (sidePanel == null){
			sidePanel = new JPanel();
			sidePanel.setPreferredSize(new Dimension(100,100));
			sidePanel.setBackground(Color.black);
		}
		
		return sidePanel;
	}
	
	//-----------------------------------------------------------------------------
	//-----------------------------Buttons & Menus Actions-------------------------
	//-----------------------------------------------------------------------------
	
	//TODO
	
	private void action_project_new(){
		System.out.println("new project action!");	//TODO new project
	}
	
	private void action_project_open(){
		System.out.println("open project action!");	//TODO open project
	}
	
	private void action_project_save(){
		System.out.println("save project action!");	//TODO save project
	}
	
	private void action_domain_open(){
		System.out.println("open domain action!");	//TODO domain open
	}

	private void action_domain_save(){
		System.out.println("save domain action!");	//TODO domain save
	}
	
	private void action_object_save(){
		System.out.println("Object Save action!");	//TODO object save
	}
	
	private void action_object_open(){
		System.out.println("Object Open action!");	//TODO object save
	}
	
	private void action_collection_open(){
		System.out.println("Object Collection Open action!");	//TODO collection save
	}

	private void action_collection_save(){
		System.out.println("Object Collection Save action!");	//TODO collection save
	}

	private void action_import(){
		System.out.println("import action!");	//TODO import
	}

	private void action_export(){
		System.out.println("export action!");	//TODO export
	}
	
	private void action_object_new(){
		System.out.println("Object New action!");	//TODO object new
	}
	
	private void action_object_remove(){
		System.out.println("Object Remove action!");	//TODO Remove save
	}
	
	private void action_object_clone(){
		System.out.println("Object Clone action!");	//TODO clone save
	}
	
	private void action_edit_domain(){
		System.out.println("edit domain action!");	//TODO edit domain
	}
	
	private void action_object_edit(){
		System.out.println("edit object action!");	//TODO domain save
	}
	
	private void action_settings(){
		System.out.println("settings action!");	//TODO settings
	}
	
	private void action_zoom_in(){
		System.out.println("zoom in action!");	//TODO zoom in
	}
	
	private void action_zoom_out(){
		System.out.println("zoom out action!");	//TODO zoom out
	}
	
	private void action_fit_page(){
		System.out.println("fit page action!");	//TODO fit to page
	}
	
	private void action_run(){
		System.out.println("run action!");	//TODO run
	}
	
	private void action_help(){
		System.out.println("Help action!");	//TODO help window
	}
	
	private void action_about(){
		System.out.println("about action!");	//TODO about window
	}
	
	private JPanel getLowerPanel() {
		if (lowerPanel == null) {
			lowerPanel = new JPanel();
			lowerPanel.setLayout(new BorderLayout(0, 0));
			lowerPanel.add(getProgressBar(), BorderLayout.NORTH);
		}
		return lowerPanel;
	}
	private JProgressBar getProgressBar() {
		if (progressBar == null) {
			progressBar = new JProgressBar();
			progressBar.setFont(new Font("Ubuntu", Font.PLAIN, 12));
			progressBar.setStringPainted(true);
			progressBar.setForeground(new Color(50, 205, 50));
			progressBar.setMinimum(0);
			progressBar.setMaximum(100);
			progressBar.setValue(0);
			progressBar.setString(Lang.PROGRESS_BAR_SPACE1 + " " + progressBar.getValue() + "% " + Lang.PROGRESS_BAR_SPACE2);
			progressBar.setVisible(false); //TODO
		}
		return progressBar;
	}
	private JScrollPane getScrollPane() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setViewportView(getDp());
		}
		return scrollPane;
	}
	private DomainDrawPanel getDp() {
		if (dp == null) {
			dp = new DomainDrawPanel();
			//dp.setPreferredSize(new Dimension(200, 1000));
		}
		return dp;
	}
}
